clear all
set more off
set matsize 2000

*input folder path    
global filepath "D:\Dropbox\NREGA Aggregate\shared NREGA lights\replication files"

	  
cd "$filepath"
use "district light panel.dta", clear

local pre "i.year#c.wage i.year#c.outputwage i.year#c.state_frac"



***********************************************
*** Table 1, Panel A. Base Analysis: Lights ***
***********************************************

*col. 1
reghdfe std_lt nregs , absorb(sno year#st) cluster(sno)
local b1 = _b[nregs]

*col. 2
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy , absorb(sno year#st) cluster(sno)
local b2 = _b[nregs]

*col. 3
reghdfe std_lt nregs if wage!=., absorb(sno year#st) cluster(sno)
local b3 = _b[nregs]

*col. 4
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy if  wage!=., absorb(sno year#st) cluster(sno)
local b4 = _b[nregs]

*col. 5
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy `pre', absorb(sno year#st) cluster(sno)
local b5 = _b[nregs]



************************************************
*** Table 2, Panel A.  Heterogeneity by wave ***
************************************************
gen nregs_nr08 = nregs*nr08
label var nregs_nr08 "NREGS $\times$ wave 3"

*col. 1
reghdfe std_lt nregs nregs_nr08 , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col 3
reghdfe std_lt nregs nregs_nr08 if  wage!=., absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 if  wage!=., absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 `pre' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]





/*** APPENDIX ***



*********************
*** Summary Stats ***
*********************
*full sample
sum avglt
sum avglt if year<2006
sum avglt if year>=2006
sum nr06 nr07 nr08 if year==2006

*restricted sample
sum avglt if wage!=.
sum avglt if year<2006 & wage!=.
sum avglt if year>=2006 & wage!=.
sum nr06 nr07 nr08 if year==2006 & wage!=.

sum rggvy wage outputwage state_frac if year==2006
sum wage outputwage state_frac if nr06==1 & year==2006
sum wage outputwage state_frac if nr07==1 & year==2006
sum wage outputwage state_frac if nr08==1 & year==2006



*****************************************************************
*** App Table 2, Panel A.  Association with levels, not trend ***
*****************************************************************
egen std_premean_lt = std(pre_meanlt)
egen std_pregrowth_lt = std(dlt00_05)

**pre-period mean
*col. 1
reghdfe std_premean_lt nr08 if year==2000, absorb(st) cluster(st)

*col. 2
reghdfe std_premean_lt nr08 if year==2000 & wage!=., absorb(st) cluster(st)


**pre-period growth
*col. 3
reghdfe std_pregrowth_lt nr08 if year==2000, absorb(st) cluster(st)

*col. 4
reghdfe std_pregrowth_lt nr08 if year==2000 & wage!=., absorb(st) cluster(st)






********************************************
*** App Table 3: Lights with Dep. Sample ***
********************************************

*** Panel A. Main Effect
*col. 1
reghdfe std_lt nregs if dep_samp!=. , absorb(sno year#st) cluster(sno)

*col. 2
reghdfe std_lt nregs i.year#i.rggvy i.year#c.dlt00_05 if dep_samp!=. , absorb(sno year#st) cluster(sno)

*col. 3
reghdfe std_lt nregs if dep_samp!=. & wage!=., absorb(sno year#st) cluster(sno)

*col. 4
reghdfe std_lt nregs  i.year#i.rggvy i.year#c.dlt00_05 if dep_samp!=. & wage!=., absorb(sno year#st) cluster(sno)

*col. 5
reghdfe std_lt nregs i.year#i.rggvy i.year#c.dlt00_05 `pre' if dep_samp!=., absorb(sno year#st) cluster(sno)



*** Panel B. Heterogeneity by wave ***
*col. 1
reghdfe std_lt nregs nregs_nr08 if dep_samp!=. , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 if dep_samp!=. , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_lt nregs nregs_nr08 if dep_samp!=.  & wage!=., absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 if dep_samp!=.  & wage!=., absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_lt nregs nregs_nr08 i.year#i.rggvy i.year#c.dlt00_05 `pre' if dep_samp!=. , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]



*** Panel C. Heterogeneity by pre-period wage ***
gen nregs_wage = nregs*wage
label var nregs_wage "NREGS $\times$ agr. wage (Rs, 1996/7)"

sum wage if dep_samp!=. & year==2005,d
local p10 = `r(p10)'
local p90 = `r(p90)'

*col. 3
reghdfe std_lt nregs nregs_wage if dep_samp!=.  , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 4
reghdfe std_lt nregs nregs_wage i.year#i.rggvy i.year#c.dlt00_05 if dep_samp!=. , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 5
reghdfe std_lt nregs nregs_wage i.year#i.rggvy i.year#c.dlt00_05 `pre' if dep_samp!=. , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'





**************************************************************
*** App Table 4, Panel A. Heterogeneity by pre-period wage ***
**************************************************************

*col. 1
reghdfe std_lt nregs nregs_wage   , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 2
reghdfe std_lt nregs nregs_wage i.year#i.rggvy i.year#c.dlt00_05  , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 3
reghdfe std_lt nregs nregs_wage i.year#i.rggvy i.year#c.dlt00_05 `pre' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'








******************************************
*** App Table 5, Panel A. Short Sample ***
******************************************
local sam "year>=2004 & year<=2010"

*col. 1
reghdfe std_lt nregs if `sam', absorb(sno year#st) cluster(sno)

*col. 2
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy if `sam', absorb(sno year#st) cluster(sno)

*col. 3
reghdfe std_lt nregs if  wage!=. & `sam' , absorb(sno year#st) cluster(sno)

*col. 4
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy if wage!=. & `sam', absorb(sno year#st) cluster(sno)

*col. 5
reghdfe std_lt nregs i.year#c.dlt00_05 i.year#i.rggvy `pre' if  `sam', absorb(sno year#st) cluster(sno)






*****************************************************
*** App Table 6, Panel A. Het with limited sample ***
*****************************************************
local sam "year>=2004 & year<=2010"

*col. 1
reghdfe std_lt nregs nregs_nr08 if `sam' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_lt nregs nregs_nr08  i.year#c.dlt00_05 i.year#i.rggvy if `sam'  , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_lt nregs nregs_nr08 if wage!=. & `sam' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_lt nregs nregs_nr08 i.year#c.dlt00_05 i.year#i.rggvy if wage!=. & `sam' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_lt nregs nregs_nr08  i.year#c.dlt00_05 i.year#i.rggvy `pre' if  wage!=. & `sam' , absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]




*********************************************
***  App Table 7, Panel A. Omitting RGGVY ***
*********************************************


*col. 1
reghdfe std_lt nregs if rggvy==0, absorb(sno year#st) cluster(sno)

*col. 2
reghdfe std_lt nregs i.year#c.dlt00_05  if  rggvy==0, absorb(sno year#st) cluster(sno)

*col. 3
reghdfe std_lt nregs if wage!=. & rggvy==0, absorb(sno year#st) cluster(sno)

*col. 4
reghdfe std_lt nregs i.year#c.dlt00_05  if  wage!=. & rggvy==0, absorb(sno year#st) cluster(sno)

*col. 5
reghdfe std_lt nregs i.year#c.dlt00_05  `pre' if rggvy==0, absorb(sno year#st) cluster(sno)




***************************************************************
*** App Table 8, Panel A. Heterogeneity when omitting RGGVY ***
***************************************************************


*col. 1
reghdfe std_lt nregs nregs_nr08 if  rggvy==0, absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_lt nregs nregs_nr08  i.year#c.dlt00_05  if  rggvy==0, absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_lt nregs nregs_nr08 if wage!=. & rggvy==0, absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_lt nregs nregs_nr08 i.year#c.dlt00_05 if  wage!=. & rggvy==0, absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_lt nregs nregs_nr08  i.year#c.dlt00_05 `pre' if  rggvy==0, absorb(sno year#st) cluster(sno)
lincom _b[nregs]+_b[nregs_nr08]



















